package com.hhdz.barrage.utils;

import android.content.Context;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.view.animation.TranslateAnimation;

import com.hhdz.barrage.R;

/**
 * Created by tangnan on 16-1-21.
 */
public class AnimationHelper {
    public static Animation createTranslateAnim(Context context, int fromX, int toX) {
        Animation anim = AnimationUtils.loadAnimation(context, R.anim.out_right_left);
        //自动计算时间
        anim.setDuration(7000+(long) (Math.abs(toX - fromX) * 1.0f / ScreenUtils.getScreenWidth(context) * 1000*Math.random()));
        return anim;
    }
}
